﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;


public partial class NewsUserControl : System.Web.UI.UserControl
{
    public String navigate_url = null;
    public String image_url = null;
    public DataTable dt = null;

    public String Image_url { get { return image_url; } set { image_url = value; } }
    public String Navigate_url { get { return navigate_url; } set { navigate_url = value; } }
    public DataTable Dt { get { return dt;} set {dt = value;} }
    
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    public void FetchDataList()
    {
        if (dt != null)
        {
            int num = dt.Rows.Count;
            if (num > 0) {
                list1.Text = dt.Rows[0]["title"].ToString();
                list1.NavigateUrl = navigate_url + "?id=" + dt.Rows[0]["news_id"].ToString();
                ul1.FindControl("l1").Visible = true;
                list1.Visible = true;
                if (num > 1) {
                    list2.Text = dt.Rows[1]["title"].ToString();
                    list2.NavigateUrl = navigate_url + "?id=" + dt.Rows[1]["news_id"].ToString();
                    ul1.FindControl("l2").Visible = true;
                    list2.Visible = true;
                    if (num > 2) {
                        list3.Text = dt.Rows[2]["title"].ToString();
                        list3.NavigateUrl = navigate_url + "?id=" + dt.Rows[2]["news_id"].ToString();
                        ul1.FindControl("l3").Visible = true;
                        list3.Visible = true;
                        if (num > 3) {
                            list4.Text = dt.Rows[3]["title"].ToString();
                            list4.NavigateUrl = navigate_url + "?id=" + dt.Rows[3]["news_id"].ToString();
                            ul1.FindControl("l4").Visible = true;
                            list4.Visible = true;
                            if (num > 4) {
                                list5.Text = dt.Rows[4]["title"].ToString();
                                list5.NavigateUrl = navigate_url + "?id=" + dt.Rows[4]["news_id"].ToString();
                                ul1.FindControl("l5").Visible = true;
                                list5.Visible = true;
                            }
                        }
                    }
                }
            }
        }

    }

    public void FetchDataTitle()
    {
        if (dt != null)
        {
            title.Text = dt.Rows[1]["title"].ToString();

            char[] deli = { '.' };
            contentLabel.Text = dt.Rows[1]["details"].ToString().Split(deli)[0];
            Image1.ImageUrl = dt.Rows[1]["image_"].ToString();
            header_link.NavigateUrl = navigate_url + "?id=" + dt.Rows[1]["news_id"].ToString();
            title.NavigateUrl = navigate_url + "?id=" + dt.Rows[1]["news_id"].ToString();
            label_link.NavigateUrl = navigate_url + "?id=" + dt.Rows[1]["news_id"].ToString();
        }
    }
}